package com.yanggu.flink.datastream_api.multi_stream_transform.combine_stream

import org.apache.flink.streaming.api.scala._

/**
 * DataStream → DataStream：对两个或者两个以上的 DataStream 进行 union 操 作，产生一个包含所有 DataStream 元素的新 DataStream
 * Union两个流的泛型需要一致, 可以同时Union多个流
 * 用来合并多个流, 新的流会包含所有流中的数据
 */
object UnionDemo01 {

  def main(args: Array[String]): Unit = {
    val environment = StreamExecutionEnvironment.getExecutionEnvironment
    environment.setParallelism(1)

    //DataStream1 union DataStream2 => DataStream3
    val dataStream1 = environment.fromCollection(List(1, 2, 3, 4))
    val dataStream2 = environment.fromCollection(List(2, 3, 4, 5))

    dataStream1.union(dataStream2)
      .print("union result")

    environment.execute("UnionDemo Job")

  }

}
